package com.company;

public class Parse {

    /**
     *  byte[]、int转string
     * @param param
     * @return
     */
    public static String parseString(Object param) {
        return String.valueOf(param);
    }

    /**
     * string转任意类型
     * @param param
     * @return
     */
    public static Object parseObject(String param,Object type) {

        if (type instanceof Integer) {
            return Integer.parseInt(param);
        } else if (type instanceof Long) {
            return Long.parseLong(param);
        } else if (type instanceof Float) {
            return Float.parseFloat(param);
        } else if (type instanceof Double) {
            return Double.parseDouble(param);
        } else if (type instanceof Byte) {
            return Byte.parseByte(param);
        }
        return param;
    }
}
